<template>
	<view class="banner_comp">
    <u-swiper :list="bannerList" name="imageurl" :height="bannerInfo.height || 296" :interval="5000" :border-radius="20" :circular="false" @click="clickImg" :bg-color="bgColor"></u-swiper>
	</view>
</template>

<script>
  import {  formatImg } from '@/utils/format'
	export default {
		props: {
      mark: { // banner标记：index_banner首页，activity活动中心，camera_index拍拍拍首页，sign_index签到首页
        type: String,
        default: 'index_banner'
      },
      bgColor: { // banner标记：index_banner首页，activity活动中心，camera_index拍拍拍首页，sign_index签到首页
        type: String,
        default: '#FFFFFF'
      },
		},
		data() {
			return {
        bannerList: [],
        bannerInfo: {},
			}
		},
		computed: {
		},
    created() {
      this.$api.common.getBannerByMark({mark: this.mark}).then(res => {
        res.data.data.forEach(item => {
          item.imageurl = formatImg(item.imageurl)
          // item.imageurl = 'http://p.qlogo.cn/bizmail/jeS61Ha5UntgUcGAbpX2yxBjCA2jqtM1eMWAL4urbesN4vM4QTXdXg/0'
        })
        this.bannerList = res.data.data
        this.bannerInfo = res.data
      })
    },
		methods: {
      clickImg(index){
        if(this.bannerList[index].linkurl.indexOf('http') !== -1){
          // 跳转外链
          if(this.bannerList[index].target === '_blank'){
            // 新页面打开
            window.open(this.bannerList[index].linkurl)
          }else {
            // 旧页面打开
            window.location.href = this.bannerList[index].linkurl
          }
        }else{
          uni.navigateTo({
            url: this.bannerList[index].linkurl
          })
        }
      },
		}
	}
</script>

<style lang="scss" scoped>
  .banner_comp{
    border-radius: 20rpx;
    // box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(123,123,123,0.4);
  }
</style>
